/*
 * XInput1_3-dev - Replacement of xinput library to help with creating
 *                 drivers/debugging application
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3.0 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.
 */

#pragma once

#include "XInputCommon.h"
#include "XInputCore.h"

#pragma pack(push, 1)
typedef struct tagInterfaceInformation
{
	WORD wVersion;
	DWORD dwUsers;
	WORD Dummy1;
	WORD wVID;
	WORD wPID;
} INTERFACE_INFORMATION, *PINTERFACE_INFORMATION;
#pragma pack(pop)

namespace DeviceInfo
{
	typedef struct _XINPUT_BATTERY_INFORMATION_CONTEXT {
		BYTE *DevType;
		PXINPUT_BATTERY_INFORMATION pBatteryInformation;
	} XINPUT_BATTERY_INFORMATION_CONTEXT, *PXINPUT_BATTERY_INFORMATION_CONTEXT;

	typedef struct _XINPUT_WAIT_FOR_GUIDE_BUTTON_CONTEXT {
		HANDLE *phEvent;
		PXINPUT_LISTEN_STATE pListenState;
	} XINPUT_WAIT_FOR_GUIDE_BUTTON_CONTEXT, *PXINPUT_WAIT_FOR_GUIDE_BUTTON_CONTEXT;

	extern XInputCore::APIFunction_t g_pfnGetStateDispatcher;
	extern XInputCore::APIFunction_t g_pfnSetVibrationDispatcher;
	extern XInputCore::APIFunction_t g_pfnGetBatteryInformationDispatcher;
	extern XInputCore::APIFunction_t g_pfnGetCapabilitiesDispatcher;
	extern XInputCore::APIFunction_t g_pfnGetKeystrokeDispatcher;
	extern XInputCore::APIFunction_t g_pfnPowerOffController;
	extern XInputCore::APIFunction_t g_pfnWaitForGuideButton;
	extern XInputCore::APIFunction_t g_pfnCancelGuideButtonWait;

	PDEVICE_INFO Create(HANDLE,wchar_t const *);
	HRESULT Destroy(PDEVICE_INFO pDeviceInfo);

	HRESULT WINAPI CancelGuideButtonWait(PDEVICE_INFO pDeviceInfo, LPVOID *, uchar);
	HRESULT WINAPI GetAudioDeviceGuids(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	HRESULT WINAPI GetBatteryInformation(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	HRESULT WINAPI GetCapabilities(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	HRESULT WINAPI GetKeystroke(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	HRESULT WINAPI WaitForGuideButton(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	HRESULT WINAPI PowerOffController(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);

	HRESULT IsDeviceActive(PDEVICE_INFO pDeviceInfo);
	bool MinFillFromInterface(HANDLE,PDEVICE_INFO pDeviceInfo);
	bool OnEnableSettingChanged(bool);
	void Recycle(PDEVICE_INFO pDeviceInfo);

	namespace Disabled
	{
		HRESULT WINAPI GetState(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
		HRESULT WINAPI SetVibration(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	}
	
	namespace Enabled
	{
		HRESULT WINAPI GetState(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
		HRESULT WINAPI SetVibration(PDEVICE_INFO pDeviceInfo, LPVOID *,uchar);
	}
}